<template>
  <div class="bk">
  </div>
    <div class="content">
      <img src="@/assets/img/wwl.png" alt="登录">
      <div class="close" @click="emit('closeLogin')">
        <CloseOutlined />
      </div>
      <span class="login-title">登录</span>
      <a-form
          :model="user"
          name="basic"
          :label-col="{ span: 3, offset: 2 }"
          :rules="rules"
          :wrapper-col="{ span: 17 }"
      >
        <a-form-item
            :colon="false"
            name="userName"
        >
          <template #label>
            <span class="form-title">用户名:</span>
          </template>
          <a-input v-model:value="user!.userName"
                    placeholder="请输入您的用户名"
          >
            <template #prefix>
              <user-outlined />
            </template>
            <template #suffix>
              <a-tooltip title="密码由数字、字母组成/必须以字母开头">
                <info-circle-outlined style="color: rgba(0, 0, 0, 0.45)" />
              </a-tooltip>
            </template>
          </a-input>
        </a-form-item>
        <a-form-item
            :colon="false"
            name="passWord"
        >
          <template #label>
            <span class="form-title">密码:</span>
          </template>
          <a-input-password v-model:value="user!.passWord" placeholder="请输入密码">
            <template #prefix>
              <LockOutlined />
            </template>
          </a-input-password>
        </a-form-item>
        <div class="dl">
          <a-button type="primary" size="large">
            登录
            <template #icon>
              <CrownOutlined />
            </template>
          </a-button>
        </div>
      </a-form>
      <div class="zc">
        是否还没有账号?不用担心
        <a href="#">点击这里</a>
        注册账号
      </div>
    </div>
</template>

<script setup lang="ts">
import {ref} from "vue";
import { UserOutlined, InfoCircleOutlined, LockOutlined, CrownOutlined, CloseOutlined } from '@ant-design/icons-vue';
import {Rule} from "ant-design-vue/es/form";

let user = ref<UserLoginType>({password: "", userName: ""})
let emit = defineEmits(['closeLogin'])
const rules: Record<string, Rule[]> = {
  userName: [
    { required: true, message: '请输入用户名', trigger: 'change' },
    { min: 3, max: 5, message: '用户名长度不正确！', trigger: 'blur' }
  ],
  passWord: [
    { required: true, message: '请输入密码！' },
    { min: 6, message: '密码长度不能少于6位！' },
    { max: 12, message: '密码长度不能超过12位！' },
  ]
}

</script>

<style scoped>
  .content {
    display: flex;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    flex-direction: column;
    justify-content: center;
    padding: 0.4rem;
    position: absolute;
    margin: 0 auto;
    width: 40vw;
    height: 50vh;
    background-color: #ffffff;
    border-radius: 0.4rem;
    z-index: 1001;
    box-shadow: 0 8px 8px rgba(0, 0, 0, 0.1);


    img {
      position: absolute;
      top: 0;
      left: 0;
      transform: translate(-55%, -35%);
      height: 1rem;
      width: 1rem;
    }
  }

  .login-title {
    display: flex;
    justify-content: center;
    font-size: 0.6rem;
    color: #717171;
    font-weight: 500;
  }

  .ant-form-item-explain-error {
    text-align: left;
  }

  .ant-input-affix-wrapper {
    color: #717171;
  }
  .ant-form {
    margin-top: 0.4rem;
  }
  .ant-input-affix-wrapper[data-v-c1abe6ea]{
    font-size: 0.3rem;
  }

  .form-title {
    width: 1rem;
    font-size: 0.32rem;
    font-weight: 500;
    color: #717171;
  }

  .dl {
    display: flex;
    justify-content: center;
  }

  .zc {
    display: flex;
    justify-content: center;
    font-size: 0.28rem;
    color: #515151;
    margin-top: 0.4rem;
  }

  .bk {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 120vh;
    background-color: rgba(57, 57, 57, 0.5); /* 可选的背景颜色 */
    backdrop-filter: blur(0.2rem);
    pointer-events: none;
    z-index: 1000;
  }

  .close {
    position: absolute;
    top: -0.2rem;
    right: 0.5rem;
    span {
      font-size: 16px;
      color: #4a4a4a;
    }
    span:hover {
      cursor: pointer;
    }
  }

</style>
